package com.hundun.tt_pay.pay.controller;


import com.alibaba.fastjson.JSON;
import com.hundun.domain.Result;
import com.hundun.tt_pay.pay.service.InfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 谢
 * @since 2020-05-08
 */
@RestController
@RequestMapping("/pay/info")
@Api(tags ="支付业务")
public class InfoController {

    @Autowired
    InfoService infoService;

    @ApiOperation("支付宝支付/微信支付")
    @PostMapping("userPay")
    @ApiImplicitParams({
            @ApiImplicitParam(name="openId",value="用户唯一标识",dataType="string", paramType = "query",required=true),
            @ApiImplicitParam(name="appId",value="小程序appId",dataType="string", paramType = "query",required=true),
            @ApiImplicitParam(name="type",value="支付类型 1.支付宝 2.微信",dataType="int", paramType = "query",required=true)
    })
    public Result<JSON> xcxPay(@RequestBody Map<String,String> map) throws Exception {
        return infoService.userPay(map.get("openId"),map.get("appId"),Integer.parseInt(map.get("type")));
    }





}

